package com.uzai.console.web.pyq;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.pyq.llygoods.PyqLlyGoodsUserIdDto;
import com.uzai.console.dto.pyq.llygoods.PyqLlyGoodsUserQuery;
import com.uzai.console.dto.pyq.pyqautoconfig.PyqAutoConfigDto;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.feign.UzaiBusinessFeignService;
import com.uzai.console.service.lly.LlyGoodsService;
import com.uzai.console.service.pyq.PyqAutoConfigService;
import com.uzai.console.service.pyq.PyqLlyGoodsService;
import com.uzai.console.vo.pyq.llygoods.PyqLlyGoodsUserVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 朋友圈悠友圈列表
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "悠友圈列表",tags = "个人微信|朋友圈|悠友圈列表")
@ApiSort(31)
@RestController
public class PyqYzjxGoodsUserController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(PyqYzjxGoodsUserController.class);

    @Autowired
    private PyqLlyGoodsService pyqLlyGoodsService;
    @Autowired
    private PyqAutoConfigService pyqAutoConfigService;

    @ApiOperation(value = "分页查询悠友圈列表", notes = "分页查询悠友圈列表", response = PyqLlyGoodsUserVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/pyqYzjxGoodsUser/findByList")
    public Object findPyqYzjxGoodsUserList(@RequestBody PyqLlyGoodsUserQuery pyqLlyGoodsQuery){
        return pyqLlyGoodsService.goodsUserFindByPage(pyqLlyGoodsQuery);
    }

    @ApiOperation(value = "查询悠友圈详情", notes = "查询悠友圈详情", response = PyqLlyGoodsUserVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/pyqYzjxGoodsUser/findById")
    public Object findPyqYzjxGoodsUserInfo(@RequestBody PyqLlyGoodsUserIdDto pyqLlyGoodsUserIdDto){
        return pyqLlyGoodsService.goodsUserFindById(pyqLlyGoodsUserIdDto);
    }

    @SystemLogType(model = SystemModelEnum.PyqAutoConfig, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加悠友圈自动发圈配置", notes = "添加悠友圈自动发圈配置")
    @ApiOperationSupport(order = 3)
    @PostMapping("/pyqYzjxGoodsUser/addPyqGoodsUserAutoConfig")
    public Object addPyqGoodsUserAutoConfig(@RequestBody PyqAutoConfigDto pyqAutoConfigDto){
        pyqAutoConfigDto.setRateMin(1);  //默认最小频率为1
        pyqAutoConfigDto.setRateMax(2);  //默认最大频率为2
        pyqAutoConfigDto.setType(10);    //默认为优友圈自动发送朋友圈
        pyqAutoConfigDto.setGoodsComment(1); //默认发送商品自带评论
        pyqAutoConfigService.addPyqGoodsUserAutoConfig(pyqAutoConfigDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.PyqAutoConfig, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "编辑悠友圈自动发圈配置", notes = "编辑悠友圈自动发圈配置" )
    @ApiOperationSupport(order = 4)
    @PostMapping("/pyqYzjxGoodsUser/updatePyqGoodsUserAutoConfig")
    public Object updatePyqGoodsUserAutoConfig(@RequestBody PyqAutoConfigDto pyqAutoConfigDto){
        pyqAutoConfigDto.setRateMin(1);  //默认最小频率为1
        pyqAutoConfigDto.setRateMax(2);  //默认最大频率为2
        pyqAutoConfigDto.setType(10);    //默认为优友圈自动发送朋友圈
        pyqAutoConfigDto.setGoodsComment(1); //默认发送商品自带评论
        pyqAutoConfigService.updatePyqGoodsUserAutoConfig(pyqAutoConfigDto);
        return true;
    }

}
